Multiple backdrop compositing

ABSTRACT

Methods and apparatus, including computer program products, implementing techniques for compositing a digital image. The invention performs the steps of providing a current accumulation image; identifying as the current element of the digital image to be processed a graphics element having a backdrop property, the backdrop property identifying a backdrop image into which the element is to be blended; using the element and the backdrop image to create a modified backdrop image; obtaining a shape mask for the element; and crossfading the current accumulation image with the modified backdrop image using the shape mask. The result of the crossfading becomes the current accumulation image for any further compositing.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation application of, and claims priority to, commonly-owned U.S. patent application Ser. No. 09/573,075, entitled Compositing Using Multiple Backdrops, filed on May 16, 2000. The disclosure of the above application is incorporated here by reference in its entirety.

BACKGROUND

The invention relates to techniques for creating digital images by compositing graphics elements.

A digital image is generally defined by color and alpha information. The alpha is optional. The color may be defined in any of a variety of color spaces, including a monochrome grayscale space. The image definition may be in a raster format, a vector format, or a combination of them.

In a digital graphics processing computer program, the traditional compositing loop has the following conceptual structure:

-   -   1. Initialize an accumulation buffer.     -   2. For each element to be composited in order,         -   use the element to modify the accumulation buffer.

This loop-based model corresponds closely to a layered compositing model. Other compositing models are based on trees or directed-acyclic graphs of compositing operators that combine a collection of leaf images to produce a final image. Such non-linear models are very different in their presentation to the user and the present invention is not relevant to them. In layered compositing, an element can be an object, a layer, or a group of layers or objects or both. A description of layered compositing can be found, for example, in commonly-owned U.S. Pat. No. 6,028,583.

The invention involves a reformulation of what happens when a compositing loop uses an element to modify the accumulation buffer. Every graphics program based on a layered compositing model must define how elements modify the accumulation buffer, but such definitions have been somewhat ad hoc. Examples include blending individual layers; blending a group by making a copy of the accumulation buffer, blending the grouped layers into the copy, and then using the masks for the group to crossfade the result into the accumulation buffer; blending clipping groups; and applying color adjustments by using adjustment layers.

SUMMARY

In general, in one aspect, the invention features a method, system and apparatus, including a computer program product, implementing techniques for compositing a digital image. The techniques include providing a current accumulation image; identifying as the current element of the digital image to be processed a graphics element having a backdrop property, the backdrop property identifying a backdrop image into which the element is to be blended; using the element and the backdrop image to create a modified backdrop image; obtaining a shape mask for the element; and crossfading the current accumulation image with the modified backdrop image using the shape mask. The result of the crossfading becomes the current accumulation image for any further compositing.

Embodiments may include one or more of the following features.

The current accumulation image may be stored in a current accumulation buffer. The backdrop image may be identified by identifying a backdrop buffer or the current accumulation buffer. The backdrop image may be copied to a working buffer and the modified backdrop image may be created by using the element to modify the copy of the backdrop image in the working buffer. The result of the crossfading may be stored in the current accumulation buffer. A backdrop update element may be identified as the current element of the digital image to be processed. The update element may designate an update operation to be performed on a backdrop buffer. The update operation designated by the update element may be performed.

The update operation may copy the current accumulation buffer to the backdrop buffer. The update operation may be a stack operation. Multiple backdrop buffers may be provided. The update element and the graphics element may each have a control designating which of the multiple backdrop buffers is to be used in processing the element.

The backdrop image and the modified backdrop image may each include both color and alpha information. The element may be a layer or a group of layers. The element may have a knockout property specifying that where the element overlaps older elements or parts, the newer elements or parts just replace the older elements or parts rather than blending with them.

In another aspect, the invention features a method, system, and apparatus, including a computer program product, implementing techniques for compositing a stack of graphics elements. The techniques include initializing an accumulation buffer and one or more backdrop buffers; then, processing the stack through a compositing loop of actions. The actions include processing each element in the stack that is to be blended into the accumulation buffer by copying a designated one of the accumulation or backdrop buffers to a working buffer. The designation is defined by the current element. The techniques include using the current element to modify the working buffer; obtaining a shape mask for the element; and crossfading the accumulation buffer with the working buffer using the shape mask. The result of the crossfading is stored in the accumulation buffer.

Embodiments may include one or more of the following.

For each current element that updates a particular backdrop buffer, the actions may include using the current contents of the accumulation buffer to update the particular backdrop buffer.

Advantages that can be seen in implementations of the invention include one or more of the following. With the invention, a program can composite multiple spatially varying elements into a shared backdrop in a way that they do not interact with each other, or have limited interaction with each other, and that allows the interaction to be controlled element by element.

DESCRIPTION OF DRAWINGS

FIG. 1 is a flowchart of a generalized compositing loop in accordance with the invention.

FIG. 2 is a rendered image showing traditional compositing.

FIG. 3 is a rendered image showing compositing in accordance with the invention.

Like reference symbols in the various drawings indicate like elements.

DETAILED DESCRIPTION

This disclosure will describe the features and uses of a generalized compositing loop that includes the application of a shape mask.

The alpha values of a graphics element can be broken into an opacity component and a shape component, both of which can vary spatially. The opacity component determines how the element blends while the shape portion determines where it blends. Alpha is the product of the shape and the opacity components. The shape component can be treated as defining a shape mask in terms of specially identified, positionally varying scalar values. Although shape masks frequently have hard edges, meaning that at any location their value is either 0% or 100%, indicating that the location is outside or inside the element, respectively, a shape mask can have intermediate values between 0% and 100%.

A generalized two-alpha blending operation has been defined as follows for a blend between an initial accumulation buffer and an element: result = XFade ( initial,           (Eq. 1)   XFade ( <element.color, 1>,     <Blend (initial.color, element.color), 1>,     initial.alpha),   element.alpha) The element.alpha indicates where the element exists spatially. This is described more fully in U.S. Pat. No. 6,421,460, the disclosures of which are incorporated here by reference. The Blend function in Equation 1 blends two colors in accordance with a transfer mode for color blending.

The crossfade operation XFade (<X, x>, <Y, y>, z)=<R, r> is an operation satisfying the formulas r=InterpolateAlpha (x, y, z), t=y*z/r, and R=InterpolateColor (X, Y, t). Generally, the InterpolateAlpha function is a linear interpolation function yielding r=x*(1−z)+y*z and the InterpolateColor function is a linear interpolation function yielding R=X*(1−t)+Y*t. The X, Y, and R are generally vectors of colorant values, such as vectors of RGB or CMYK values; x, y, z, and r are alpha values; and * is a scalar multiplication operator. When used in the above equations, color and alpha values are normalized to range from zero to one, inclusive.

If the element alpha values are broken into an opacity component and a shape component, one can express Equation 1, above, as: result = XFade ( initial,   XFade ( initial,     XFade ( <element.color, 1> ,       <Blend ( initial.color, element.color), 1> ,       initial.alpha),     element.opacity),   element.shape) This follows from the observation that XFade (A, B, t * u)=XFade (A, XFade (A, B, t), u).

This decomposition can be used to refine the compositing loop by defining an implementation of “use the element to modify the accumulation buffer” as follows:

-   -   1. Determine a blended interior content for the element. (The         blended interior content includes color information and opacity         information if opacity is being accumulated but not any shape         information. That is, blended interior content describes the         compositing results inside the shape.) This step generally         involves a calculation, but it may involve no more than copying         or identifying the content.     -   2. Determine a shape mask for the element.     -   3. Crossfade the initial accumulation buffer with the blended         interior content using the shape mask.

In performing the above three steps, using the color data for an element as its content and the alpha data as its shape mask results in the traditional normal mode, Porter-Duff OVER style compositing. (See, T. Porter and T. Duff, “Compositing Digital Images”, SIGGRAPH 84, pp. 253-59 (1984).)

Calculation of the blended interior content may or may not depend on the existing accumulation buffer values, so to cover the general case, the refinement can be expanded into the four steps shown below:

-   -   1a. Copy the accumulation buffer into a blended interior content         buffer.     -   1b. Use the element to modify the blended interior content         buffer.     -   2. Determine a shape mask for the element.     -   3. Crossfade the accumulation buffer with the blended interior         content buffer using the shape mask.

In blending operations where the blended interior content buffer is simply overwritten with the element color, step 1a is unnecessary; and program optimization can eliminate it.

The foregoing steps 1a, 1b, 2, and 3 define a general process for “using the element to modify the accumulation” that allows a graphics program to perform an essentially arbitrary action at step 1b, but puts the arbitrary action in the context of modifying a buffer that will be crossfaded into the accumulation using a shape mask. Examples of the kinds of actions that can be performed at step 1b include:

-   -   blending the color data for a layer with the blended interior         content buffer using the mode and opacity of the layer;     -   applying a color adjustment to the color data in the blended         interior content buffer;     -   applying a general filtering operation to the data in the         blended interior content buffer—e.g., a blurring filter; and     -   blending the constituent elements of a group into the blended         interior content buffer.

The shape mask can be determined—i.e., calculated, derived, or otherwise obtained—in a variety of ways. For example, the shape mask can be derived from the element alone or defined as being some mask in the element. It can be calculated using the element, the accumulation buffer, the blended interior content buffer, or any combination of them. Examples of deriving the shape mask from the element itself include using the combination of one or more masks in the element to compute an effective shape mask. Examples of computing the shape mask from other data include using the color of values in the accumulation buffer to determine which areas are eligible for blending.

As shown in FIG. 1, a generalized compositing loop 100 initializes the blended interior content buffer using arbitrary previous accumulation states. In fact, arbitrary images can be used, but that effect can be achieved by (i) compositing the arbitrary images with the accumulation in such a way that they block out everything and then (ii) restoring the underlying data.

Because the initial contents for the blended interior content buffer essentially serve as a backdrop for blending, this specification will refer to having multiple potential initial states as having multiple backdrops. Backdrops are copies of the accumulation created at various points in the compositing process. In the implementation being described, the copies are made from the current accumulation buffer into a backdrop buffer, of which there may be more than one. Backdrop buffers are modified when special elements are processed by the compositing loop; these elements will be referred to as backdrop update elements.

Thus, the following actions are performed by an implementation of the generalized compositing loop 100:

-   -   1. Initialize the accumulation buffer (step 102).     -   2. Initialize the backdrop buffers (step 104).     -   3. For each element, taken in a compositing order (step 106):         -   3a. If the element is a backdrop update element (“yes”             branch of decision step 108),             -   Update the backdrop buffer or buffers indicated by the                 element using the current accumulation buffer contents,                 generally by copying (step 110);         -   3b. Else (i.e., if the element is not a backdrop update             element) (“no” branch of decision step 108),             -   Copy the appropriate backdrop buffer or the current                 accumulation buffer as designated by the element to the                 blended interior content buffer (step 112);             -   Use the element to modify the blended interior content                 buffer (step 114);             -   Calculate the shape mask for the element (step 116); and             -   Crossfade the accumulation buffer with the blended                 interior content buffer using the shape mask, leaving                 the result in the accumulation buffer (step 118).

If multiple backdrop buffers are supported, which backdrop buffer is selected for copying (in step 112) can be selected by the element, for example by a control defined through user interaction with the graphics program. Similarly, a control can select whether a backdrop buffer or the current accumulation buffer is to be copied to the blended interior content buffer in that step.

The process of updating a backdrop buffer in its simplest form involves copying the accumulation buffer to the backdrop buffer. In more sophisticated implementations, one can have backdrop buffers defining a stack of images. In this case, updating the backdrop buffer can include pushing the contents of the accumulation buffer onto the stack, popping the top element from the stack, or replacing the top element of the stack with the contents of the accumulation buffer.

The decision when to copy and where to copy the accumulation and the decision as to which buffer to use as the backdrop for an element can be user designated, or they can be derived by the system from structural properties of the elements, or both. User designation can be implemented by giving a user of the graphics program the ability to define and place an update element in an image compositing stack and the ability to define a control selecting a backdrop buffer or the current accumulation buffer as the source to be copied into the blended interior content buffer (in step 112). An update element can be represented in the user interface as a copy-to-backdrop layer, for example, and uses of the corresponding backdrop buffer can be represented by a reference to the copy-to-backdrop layer. Alternatively, or in addition, the program can be implemented to cause backdrop buffer updates and references to occur automatically to create the effects required by the structure and effects of the image being composited.

The shape mask determination can be defined to depend on the element, the blended interior content buffer, the accumulation buffer, any of the backdrop buffers, or a combination of these. In addition, when computing the blended interior content buffer, one can use the accumulation buffer in addition to the designated backdrop buffer.

Among the advantages of the generalized compositing loop 100 is that it enables a program to implement and a user to create knockout effects easily. In a knockout effect, an element punches through its immediately underlying elements to blend with an earlier state of the accumulation. Using the features of the generalized compositing loop 100 to create knockout effects has the advantage that the implementation is localized in the sense that it alters the behavior of the basic compositing loop rather than forcing individual elements to account for knockout group effects.

A user can create a knockout effect by explicitly defining the controls and update elements required to create the effect. However, providing access to these features may be confusing to users, and a simpler user interface can be implemented as follows. The user interface allows a user to identify an element of an image as a knockout element and to specify one of three generic levels to use as the backdrop. One choice is “none”, which blends the element with the current accumulation for the group in which the element is found. The other two are “shallow”, which uses the closest natural place to stop as backdrop, and “deep”, which uses the last available place to stop as backdrop. The implementation will also stop a knockout where necessary to avoid nonsensical effects.

FIGS. 2 and 3 provide an example of a knockout effect. Each figure shows a composited image of three elements: a background image, a partially opaque square with a glowing edge, and a circle with an inner shadow that inverts its interior. FIG. 2 shows the image rendered with a traditional compositing approach. FIG. 3 shows the image rendered with the circle set to use the state of the accumulation underneath the square as its backdrop. Note that in the second image, the circle punches through the square to invert just the underlying data.

The invention can be used to build images having a series of ‘filter layers’, each of which filtered the same original image, by having a backdrop update element in the image stack copy the original image to a backdrop buffer for use by later-composited elements that define the filter layers. If elements can accept multiple backdrop inputs, an element can be defined that filters the original image and then perform a color blend with the current accumulation. Again, such an element can be defined as a layer through a user interface.

A further implementation provides a user interface through which a user can establish a series of nested groups of elements, where each group establishes a new background, and where the individual elements specify how many levels up the grouping hierarchy to look for a background.

The invention can be implemented in digital electronic circuitry, or in computer hardware, firmware, software, or in combinations of them. Apparatus of the invention can be implemented in a computer program product tangibly embodied in a machine-readable storage device for execution by a programmable processor; and method steps of the invention can be performed by a programmable processor executing a program of instructions to perform functions of the invention by operating on input data and generating output. The invention can be implemented advantageously in one or more computer programs that are executable on a programmable system including at least one programmable processor coupled to receive data and instructions from, and to transmit data and instructions to, a data storage system, at least one input device, and at least one output device. Each computer program can be implemented in a high-level procedural or object-oriented programming language, or in assembly or machine language if desired; and in any case, the language can be a compiled or interpreted language. Suitable processors include, by way of example, both general and special purpose microprocessors. Generally, a processor will receive instructions and data from a read-only memory and/or a random access memory. Generally, a computer will include one or more mass storage devices for storing data files; such devices include magnetic disks, such as internal hard disks and removable disks; magneto-optical disks; and optical disks. Storage devices suitable for tangibly embodying computer program instructions and data include all forms of non-volatile memory, including by way of example semiconductor memory devices, such as EPROM, EEPROM, and flash memory devices; magnetic disks such as internal hard disks and removable disks; magneto-optical disks; and CD-ROM disks. Any of the foregoing can be supplemented by, or incorporated in, ASICs (application-specific integrated circuits).

To provide for interaction with a user, the invention can be implemented on a computer system having a display device such as a monitor or LCD screen for displaying information to the user and a keyboard and a pointing device such as a mouse or a trackball by which the user can provide input to the computer system. The computer system can be programmed to provide a graphical user interface through which computer programs interact with users.

The invention has been described in terms of particular implementations and uses. Other implementations and uses are within the scope of the following claims. For example, the steps of the invention can be performed in a different order and still achieve desirable results. Elements can be defined to use multiple backdrops. Optimization can be implemented to eliminate unnecessary steps. A program can infer when backdrop updates should occur from the structure of the image being composited. A program can infer which backdrops should be selected from the structure of the image being composited. Rather than being executed on the definition of an image directly, the compositing loop can be used to generate nodes in a graph of the operations to be performed to generate the final image, which graph can be optimized. A graph derived from the compositing loop and the definition of an image can be processed serially or, on appropriate computing platform, processed in parallel. 

1. A computer program product for compositing graphics elements having a compositing order, the computer program product being tangibly embodied in a machine-readable storage device and comprising instructions operable to cause a programmable processor to perform operations comprising: initializing an accumulation buffer and one or more backdrop buffers and then processing the graphics elements taken in the compositing order through a compositing loop of actions, the actions comprising processing each graphics element in order by: determining whether the graphics element is a backdrop update element; if the graphics element is a backdrop update element, identifying one or more backdrop buffers associated with the graphics element and updating each of the one or more backdrop buffers using the current accumulation buffer contents; and if the graphics element is not a backdrop update element, identifying a source buffer, the source buffer being the accumulation buffer or a backdrop buffer; copying the source buffer to a working buffer; using the element to modify the working buffer; determining a shape mask for the graphics element; and crossfading the accumulation buffer with the working buffer using the shape mask, leaving the result in the accumulation buffer.
 2. The product of claim 1, wherein identifying a source buffer comprises identifying the source buffer as designated by the graphics element.
 3. The product of claim 1, wherein identifying a source buffer comprises identifying the source buffer from among multiple backdrop buffers.
 4. The product of claim 1, wherein the action of updating a first backdrop buffer comprises copying the accumulation buffer to the first backdrop buffer.
 5. The product of claim 1, wherein a second backup buffer defines a stack of images, and the action of updating the second backdrop buffer comprises at least one of pushing the contents of the accumulation buffer onto the stack of images, popping a top element from the stack, or replacing the top element of the stack with the contents of the accumulation buffer.
 6. The product of claim 1, wherein determining the shape mask depends on at least one of the graphics element, the working buffer, the accumulation buffer, or any of the backdrop buffers.
 7. The product of claim 1, wherein the instructions to perform the compositing loop action of using the element to modify the working buffer comprise instructions to perform the actions of: applying a general filtering operation to the data in the working buffer.
 8. The product of claim 7, wherein the filtering operation is a blurring operation.
 9. The product of claim 1, wherein the instructions to perform the compositing loop action of using the element to modify the working buffer comprise instructions to perform the actions of: applying a color adjustment to the color data in the working buffer; and blending the constituent elements of a group into the working buffer.
 10. The product of claim 1, wherein the one or more backdrop buffers each contain a copy of the accumulation buffer created at some point in the compositing process.
 11. The product of claim 1, further comprising instructions operable to cause a programmable processor to perform operations comprising: receiving a user input that defines a first backdrop update element and places the first update element into the compositing order.
 12. The product of claim 11, further comprising instructions operable to cause a programmable processor to perform operations comprising: receiving a user input associating one or more backdrop buffers with the first backdrop update element.
 13. The product of claim 1, further comprising instructions operable to cause a programmable processor to perform operations comprising: receiving a user input that selects a backdrop buffer or the current accumulation buffer as the source buffer to be copied into the working buffer for a particular graphics element.
 14. The product of claim 1, wherein the working buffer is used for storing color information and opacity information but not any shape information.
 15. The product of claim 1, wherein the instructions to perform the compositing loop action of identifying one or more backdrop buffers associated with a backdrop update element comprises instructions to identify multiple backdrop buffers associated with the backdrop update element.
 16. A computer program product tangibly embodied in a machine-readable storage device and comprising instructions operable to cause a programmable processor to perform operations comprising: identifying a graphics element in a compositing order, the graphics element identifying a source image from among a plurality of images; copying the source image into a working buffer; using the element to modify the working buffer; determining a shape mask for the graphics element; and crossfading a first image with the modified working buffer using the shape mask.
 17. The product of claim 16, wherein the first image is an accumulation image.
 18. The product of claim 17, wherein the plurality of images comprises the accumulation image.
 19. The product of claim 16, wherein using the element to modify the working buffer comprises: blending the color data for a layer with the working buffer using the mode and opacity of the layer.
 20. The product of claim 16, wherein using the element to modify the working buffer comprises: applying a color adjustment to the color data in the working buffer; and blending the constituent elements of a group into the working buffer.
 21. The product of claim 16, wherein using the element to modify the working buffer comprises: applying a general filtering operation to the data in the working buffer.
 22. The product of claim 21, wherein the filtering operation is a blurring operation.
 23. A computer program product tangibly embodied in a machine-readable storage device and comprising instructions operable to cause a programmable processor to perform operations comprising: receiving a first input from a user through a user interface, the first input placing a backdrop update element in an image stack, the backdrop update element specifying that a first image is to be copied to a first backdrop buffer when the backdrop element is processed in compositing the image stack; and receiving a second input and a third input from the user through the user interface, the second and third input respectively placing a first and a second filter element in the image stack at a later compositing position than the backdrop update element, each of the first and the second filter element specifying operations to be performed when the respective filter element is processed in compositing the image stack, the first element specifying (i) a first filter operation to be performed on the first image from the first backdrop buffer to produce a first filtered image and (ii) a color blend of the first filtered image to be performed into a current accumulation buffer, the second element specifying (i) a second filter operation to be performed on the first image from the first backdrop buffer to produce a second filtered image and (ii) a color blend of the second filtered image to be performed with into the current accumulation buffer.
 24. The product of claim 23, wherein: the backdrop element specifies that the first image is to be copied to multiple backdrop buffers including the first backdrop buffer; and the first and the second filter element are each defined as a respective layer in the image stack. 